There was a time, not so very long ago, when cubic equations were quite challenging. Today, we just hand them over to our CAS and magically get the answer. The general cubic equation is written as follows: $0=ax^{3}+bx^{2}+cx+d$. A solution is meant by “solve for $x$” and in my case, I am usually only interested in the real solution(s) rather than any imaginary answers. Without loss of generality, the coefficients can be divided by $a$ to obtain: $$0=x^{3}+px^{2}+qx+r$$ where I have made a substitution into the original equation: $p=b/a\quad q=c/a\quad r=d/a$. With a little algebraic effort, the three answers can be given. $$\text{denom}=-\frac{p^{3}}{27}+\frac{pq}{6}-\frac{r}{2}+\frac{\sqrt{-\frac{1}{3}p^{2}q^{2}+\frac{4}{3}q^{3}+\frac{2}{3}r\left(2p^{3}-9pq\right)+9r^{2}}}{6}$$ $$n=p^{2}-3\,q$$ $$m_{1}=-i\cdot \sqrt{3}+1$$ $$m_{2}=i\cdot\sqrt{3}+1$$ $$X1=-\frac{n\cdot m_{1}}{18\cdot denom^{\frac{1}{3}}}-\frac{1}{2}denom^{\frac{1}{3}}\cdot m_{2}-\frac{p}{3}$$ $$X2=-\frac{n\cdot m_{2}}{18\cdot denom^{\frac{1}{3}}}-\frac{1}{2}denom^{\frac{1}{3}}\cdot m_{1}-\frac{p}{3}$$ $$X3=\frac{n}{9\cdot denom^{\frac{1}{3}}}+denom^{\frac{1}{3}}-\frac{p}{3}$$ Sometimes, when coercing the result into a single real + imaginary part, the imaginary part is a number on the order of $10^{-15}$ which should have been zero. If that happens, make sure that it is just some kind of round off error in the machines. When a calculator takes a root, such as $\sqrt[3]{17}$ it just returns the principle root. The actual cube root of $17$ is $$\sqrt[3]{17}=\left[\begin{array}{c} 2.57128159065824\\ -1.28564079532912+2.22679517779329\cdot i\\ -1.28564079532912-2.22679517779329\cdot i \end{array}\right]$$ To find these additional roots another way, see the section on De Moivre's theorem. If we use the method here, we would write $x^{3}-17=0$. $p=0;\quad q=0;\quad r=-17$. Plugging in terms for $X1,X2,\text{ and }X3$ gives the same real and imaginary roots. The denominator term comes out as $17$ so the three answers are $$X1=-\frac{1}{2}\sqrt[3]{17}\cdot\left(-i\cdot\sqrt{3}+1\right)$$ $$X2=-\frac{1}{2}\sqrt[3]{17}\cdot\left(i\cdot\sqrt{3}+1\right)$$ $$X3=\sqrt[3]{17}$$ The equations below for $X1,X2$, and $X3$ are direct output from a CAS for the solution to $0=x^{3}+px^{2}+qx+r$.
We can make a sketch of this equation and find that it has 3 real roots. If a CAS is used to find the roots, we get $$\left\{ x=\frac{-10\;\sqrt{2}+40}{7},x=\frac{10\;\sqrt{2}+40}{7},x=10\right\} .$$ What happens when we use the $p,q,r$ method presented above? $$p=b/a\quad q=c/a\quad r=d/a$$ $$p=-15/(7/10)=-150/7$$ $$q=100/(7/10)=1000/7$$ $$r=-200/(7/10)=-2000/7$$ Now we compute $n=p^{2}-3q$. $\quad n=1500/49$. Next we compute $m_{1}$ and $m_{2}$. $$m_{1}=-i\sqrt{3}+1$$ $$m_{2}=i\sqrt{3}+1$$ Now we compute the denominator term. $$\text{denom}=-\frac{p^{3}}{27}+\frac{pq}{6}-\frac{r}{2}+\frac{\sqrt{-\frac{1}{3}p^{2}q^{2}+\frac{4}{3}q^{3}+\frac{2}{3}r\left(2p^{3}-9pq\right)+9r^{2}}}{6}$$ $$\text{denom}=\,1000\cdot\frac{\text{ί}}{441}\;\sqrt{6}-\frac{1000}{343}$$ Finally, we use all of this to find the three roots. $$X1=-\frac{n\cdot m_{1}}{18\cdot denom^{\frac{1}{3}}}-\frac{1}{2}denom^{\frac{1}{3}}\cdot m_{2}-\frac{p}{3}=\mathbf{7.7346-0i}$$ $$X2=-\frac{n\cdot m_{2}}{18\cdot denom^{\frac{1}{3}}}-\frac{1}{2}denom^{\frac{1}{3}}\cdot m_{1}-\frac{p}{3}=\mathbf{3.694+0i}$$ $$X3=\frac{n}{9\cdot denom^{\frac{1}{3}}}+denom^{\frac{1}{3}}-\frac{p}{3}=\mathbf{10+0i}$$